package com.china08.yxyapi.api.manage.sch.platform.xiaoben.kecheng;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.repository.db.YxyLessonsSchoolLessonRepository;

@CrossOrigin
@RestController
public class KeChengStatusCountController extends YxyApiBaseController {

    @Autowired
    YxyLessonsSchoolLessonRepository lessonRepository;

    @RequestMapping(value = "/api_yw/manage/sch/xiaoben/kecheng/status/count", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel process(HttpServletRequest request, HttpServletResponse response) {
        String schoolId = getProfile(request, response).getSchoolId();
        Integer status = 1;
        Integer count = lessonRepository.countByStatusAndSchoolId(status, schoolId);
        RespModel respModel = new RespModel();
        respModel.count = count;
        return respModel;
    }

    public static class RespModel extends YxyApiRespModel {
        public Integer count;
    }
}
